﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using RpgLibrary.EffectClasses;

namespace RpgLibrary.ItemClasses
{
    public class Weapon : BaseItem
    {
        #region Field Region
        
        Hands hands;
        int attackValue;
        int attackModifier;
        DamageEffectData damageEffectData;
        
        #endregion
        
        #region Property Region
        
        public Hands NumberHands
        {
            get { return hands; }
            protected set { hands = value; }
        }
        
        public int AttackValue
        {
            get { return attackValue; }
            protected set { attackValue = value; }
        }
        
        public int AttackModifier
        {
            get { return attackModifier; }
            protected set { attackModifier = value; }
        }

        public DamageEffectData DamageEffect
        {
            get { return damageEffectData; }
            protected set { damageEffectData = value; }
        }
        
        #endregion
        
        #region Constructor Region
        
        public Weapon(
            string weaponName,
            string weaponType,
            int price,
            float weight,
            Hands hands,
            int attackValue,
            int attackModifier,
            DamageEffectData damageEffectData,
            params string[] allowableClasses)
            : base(weaponName, weaponType, price, weight, allowableClasses)
        {
            NumberHands = hands;
            AttackValue = attackValue;
            AttackModifier = attackModifier;
            DamageEffect = damageEffectData;
        }

        #endregion
        
        #region Abstract Method Region
        
        public override object Clone()
        {
            string[] allowedClasses = new string[allowableClasses.Count];
            for (int i = 0, cnt = allowableClasses.Count; i < cnt; i++)
                allowedClasses[i] = allowableClasses[i];
            Weapon weapon = new Weapon(
                Name,
                Type,
                Price,
                Weight,
                NumberHands,
                AttackValue,
                AttackModifier,
                DamageEffect,
                allowedClasses);

            return weapon;
        }

        public override string ToString()
        {
            return String.Format("{0}, {1}, {2}, {3}, {4}, {5}",
                base.ToString(),
                NumberHands,
                AttackValue,
                AttackModifier,
                DamageEffect, 
                String.Join(", ", allowableClasses)
            );
        }
        #endregion
    }
}